<!DOCTYPE html>
<html>
 <head>
  <title>js原型对象</title>
  <meta charset="utf-8">
 </head>
 <body>
  <script>
	function Animal() {
		this.name = 'dongwu'
		this.eat = function() {
			return this.name+'eating...'
		}
	}
	
	//原型对象方法
	Animal.prototype.run = function() {
		return this.name + 'running'
	}

	var animal = new Animal()
	console.log( animal.eat() )
	console.log( animal.run() )

	function Dog() {
		this.name = 'dog'
	}
	Dog.prototype = new Animal()
	Dog.prototype.constructor = Dog
	
	var dog = new Dog
	console.log( dog.eat() )
	console.log( dog.run() )
	
	
	</script>
 </body>
</html>
